package org.BUPT.api.controller;

import org.BUPT.admin.system.validator.UserValid;
import org.BUPT.common.vo.ResultVo;
import org.BUPT.entity.QuestionBO;
import org.BUPT.entity.User;
import org.BUPT.modules.system.domain.U;
import org.BUPT.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/user")
public class UserManagerController {

    @Autowired
    private UserService service;

    @Autowired
    private InterfaceController interfaceController;

    @GetMapping("/{id}")
    public User getUser(@PathVariable int id){
        User user = new User();
        user.setId(id);
        user.setUsername("wzy");
        return user;
    }

    @GetMapping("/questionRecommend/{id}")
    public List<QuestionBO> questionRecommend(@PathVariable Long id){
        return service.questionRecommend(id);
    }

    @PostMapping("/updatePWD/{username}/{password}")
    public User updatePWD(@PathVariable String username, @PathVariable String password){
        return service.updatePWD(username, password);
    }

    @GetMapping("/remark/{user}")
    public User getRemark(@PathVariable User user){
        return interfaceController.getUserInfo(user);
    }


    @PostMapping("/update/{user}")
    public ResultVo update(@PathVariable User user){
        UserValid userValid = new UserValid();
        return interfaceController.userInfo(userValid, user);
    }

    @PostMapping("/editPwd/{original}/{password}/{confirm}")
    public ResultVo editPwd(@PathVariable String original, @PathVariable String password, @PathVariable String confirm){
        return interfaceController.editPwd(original,password,confirm);
    }



}
